Skip to content

feat: optimize with iterators #3652

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

BobTheBuidler
Copy link
Contributor

@BobTheBuidler BobTheBuidler commented Mar 25, 2025

What was wrong?

The formatters init quite a few lists each run, and can be made much more efficient using iterators. This PR does so.

I figured this was more important than the logger stuff in my last PR so finished this one up first.

Related to Issue # N/A
Closes # N/A

How was it fixed?

creation of an IteratorProxy class that allows map objects to be passed thru the formatters instead of fully materializing a list every step of the way

Todo:

  • Clean up commit history
  • Add or update documentation related to these changes
  • Add entry to the release notes

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->


@curry
def abi_data_tree(types: Sequence[TypeStr], data: Sequence[Any]) -> List[Any]:
def abi_data_tree(types: Sequence[TypeStr], data: Sequence[Any]) -> "map[ABITypedData]":
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idea for more optimization: rip out this func and replace it with a lambda which would have less overhead than using curry

[abi_data_tree(types)],
map(data_tree_map, normalizers),
[partial(recursive_map, strip_abi_type)],
return pipe(
Copy link
Contributor Author

@BobTheBuidler BobTheBuidler Apr 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could be further optimized by caching the pipe per-method as a compose object

@BobTheBuidler BobTheBuidler marked this pull request as ready for review April 5, 2025 17:07
@BobTheBuidler BobTheBuidler force-pushed the patch-3 branch 8 times, most recently from 11a0672 to 67b1fbc Compare April 18, 2025 20:40
@kclowes
Copy link
Collaborator

kclowes commented Apr 24, 2025

This looks like a combination of a few of your other PRs? Feel free to ping me once tests are passing, and let me know the order I should look at them. Thanks!

@BobTheBuidler
Copy link
Contributor Author

BobTheBuidler commented Apr 25, 2025

Yes, this was the original PR that ended up going beyond its scope. I wanted to make it easier on you so I'm rebasing this one as we handle the others and we can handle it towards the end.

@BobTheBuidler
Copy link
Contributor Author

BobTheBuidler commented May 19, 2025

I've rebased this on top of all the PRs we merged and this is now just one minor tweak, ready for review.

tldr we were initing tuples that weren't necessary and can just pass generators around instead

this does change the API but both functions are internal and the codebase handles the change just fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants